package com.chemyoo;

import java.lang.reflect.Field;
import java.util.List;

import com.chemyoo.model.QueryParam;

public class DemoApp
{
	public static void main(String[] args)
	{
//		System.err.println(JSONObject.toJSONString(new HnzljdSysTbtzglPo(), SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue));
		List<Field> map = AttributesUtils.getFieldsWithAnnotation(QueryParam.class);
		StringBuilder sb = new StringBuilder();
		sb.append("<sql id=\"").append(QueryParam.class.getSimpleName()).append("Where\">\r\n");
		sb.append("\t<where>\r\n");
		for(Field f : map) 
		{
			String key = f.getName();
			sb.append("\t\t<if test=\"" + key + " != null and " + key + " != ''\">\r\n");
			sb.append("\t\t\tand " + key + " = #{" + key + "}\r\n");
			sb.append("\t\t</if>\r\n");
		}
		sb.append("\t<where>\r\n");
		sb.append("</sql>");
		System.err.println(sb.toString());
	}

}
